package com.atguigu.crowd.api;

import com.atguigu.crowd.util.ResultEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.concurrent.TimeUnit;

@Component
@FeignClient("redis-provider")
public interface RedisRemoteService {
    @RequestMapping("/set/redis/key/value/remote")
    ResultEntity<String> setRedisKeyValueRemote(
            @RequestParam("key") String key,
            @RequestParam("value") String value);

    @RequestMapping("/set/redis/key/value/remote/with/timeout")
    ResultEntity<String> setRedisKeyValueRemoteWithTimeout(
            @RequestParam("key") String key,
            @RequestParam("value") String value,
            @RequestParam("time") long time,
            @RequestParam("timeUnit") TimeUnit timeUnit);

    @RequestMapping("/get/redis/string/value/by/key")
    ResultEntity<String> getRedisStringValueByKeyRemote(@RequestParam("key") String key);

    @RequestMapping("/remove/redis/key/remote")
    ResultEntity<String> removeRedisKeyRemote(@RequestParam("key") String key);


    @RequestMapping("/zset/redis/key/score/value/remote")
    ResultEntity<String> setRedisZsetRemote(
            @RequestParam("key") String key,
            @RequestParam("score")double score,
            @RequestParam("projectName") String projectName
    );

    //排行榜
    @RequestMapping("/zrevrange/redis/key/score/value/remote")
    ResultEntity<String> getRedisRangeRemote(
            @RequestParam("key") String key,
            @RequestParam("startIndex")Integer startIndex,
            @RequestParam("endIndex")Integer endIndex
    );

    @RequestMapping("zsetAll/redis/key/score/value/remote")
    ResultEntity<String> setRedisZsetAllRemote( @RequestParam("key") String key,
                                                @RequestParam("score")Integer score);

}
